using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class CommentMap : EntityTypeConfiguration<Comment>
    {
        public CommentMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Contents)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(t => t.AttachMent)
                .HasMaxLength(256);

            // Table & Column Mappings
            this.ToTable("Comments");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Contents).HasColumnName("Contents");
            this.Property(t => t.CreatedAt).HasColumnName("CreatedAt");
            this.Property(t => t.UpdatedAt).HasColumnName("UpdatedAt");
            this.Property(t => t.ObjectId).HasColumnName("ObjectId");
            this.Property(t => t.ObjectType).HasColumnName("ObjectType");
            this.Property(t => t.AttachMent).HasColumnName("AttachMent");
            this.Property(t => t.IsLead).HasColumnName("IsLead");
            this.Property(t => t.IsDeleted).HasColumnName("IsDeleted");
            this.Property(t => t.DeletedById).HasColumnName("DeletedById");
            this.Property(t => t.ParentId).HasColumnName("ParentId");
            this.Property(t => t.CreatorId).HasColumnName("CreatorId");

            // Relationships
            this.HasRequired(t => t.DocumentInbox)
                .WithMany(t => t.Comments)
                .HasForeignKey(d => d.ObjectId);

        }
    }
}
